<div class="headerbar">

    <a class="menutoggle"><i class="fa fa-bars"></i></a>

    <div class="header-right">
        <ul class="headermenu">

            <li>
                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        <img src="../images/photos/loggeduser.png" alt="" />
                        {{$ADMIN_REAL_NAME}}
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-usermenu pull-right">
                        <li><a href="javascript:set_password();"><i class="glyphicon glyphicon-user"></i> 修改密码</a></li>
                        <li><a href="javascript:set_weixin();"><i class="glyphicon glyphicon-cog"></i>
                            {{if $ADMIN_OPEN_ID}}
                            重新绑定微信
                            {{else}}
                            绑定微信
                            {{/if}}
                        </a></li>
                        <!--<li><a href="#"><i class="glyphicon glyphicon-cog"></i> Account Settings</a></li>-->
                        <!--<li><a href="#"><i class="glyphicon glyphicon-question-sign"></i> Help</a></li>-->
                        <li><a href="/login/logout"><i class="glyphicon glyphicon-log-out"></i> 退出</a></li>
                    </ul>
                </div>
            </li>
            <li style="display:none;">
                <button id="chatview" class="btn btn-default tp-icon chat-icon">
                    <i class="glyphicon glyphicon-comment"></i>
                </button>
            </li>
        </ul>
    </div><!-- header-right -->

</div><!-- headerbar -->


<div id="set_password" style="display: none;">
    <div class="layui-form-item" style="margin:10px;">
        <form>
            <div  class="form-group">
                <label > 原始密码<span style="color:red;">*</span></label>
                <input class="form-control" placeholder="原始密码" name="old_password" type="text" value="" >
            </div>

            <div  class="form-group">
                <label > 新密码<span style="color:red;">*</span></label>
                <input class="form-control" placeholder="新密码" name="password" type="text" value="" >
            </div>

        </form>
    </div>
</div>
<div id="set_weixin" style="display: none;">
    <div class="layui-form-item" style="margin:10px;">

    </div>
</div>

<script>
    function set_password() {
        $("#set_password form")[0].reset();
        openDialog2({title:"修改密码",area: ['500', "300"],content:$("#set_password"),clone:true,before:function (layero) {
            },
            yes:function (index,layero) {
                var data = {};
                var is_false = false;
                $("input[type!='radio'][type!='checkbox'],select,textarea,input[type='radio']:checked,input[type='checkbox']:checked",layero).each(function () {
                    var name = $(this).attr("name");
                    var ignore = $(this).attr("data-ignore");
                    if(name)
                    {
                        var value = $(this).val();
                        if(value)
                        {
                            data[name] = value;
                            $(this).parents(".form-group").removeClass("has-error");
                        }else{
                            if (ignore != "true")
                            {
                                $(this).parents(".form-group").addClass("has-error");
                                is_false = true;
                            }
                        }
                    }
                });
                if(is_false)
                {
                    return false;
                }

                AjaxCommen("GET","/adminlist/ajax_set_password",data,function (msg) {
                    if(msg.error === 0)
                    {
                        layero.close();
                        openMsg("修改成功，重新登录");
                        setTimeout(function () {
                            location.href = "/login/logout";
                        },1000);
                    }
                });
            }
        });
    }
    function set_weixin()
    {
        openDialog2({title:"修改密码",area: ['300', "400"],content:$("#set_weixin"),clone:true,btn:[],before:function (layero) {
            $("#set_weixin>div",layero).html('<img src="/login/weixin_token?t='+(new Date().getTime())+'" width="100%" >');
            $("#set_weixin>div img",layero).click(function(){
                $(this).attr("src",'/login/weixin_token?t='+(new Date().getTime()));
            });
            }

        });
    }

</script>